package com.future.mayi.qsale.response;

import com.future.baselib.entity.BaseResponse;
import com.future.mayi.app.App;
import com.future.mayi.qsale.model.RedPacketInfoModel;

import org.json.JSONException;

import java.util.Collections;
import java.util.List;

/**
 * Created by Administrator on 2018/8/21.
 */

public class RedPacketInfoResponse extends BaseResponse {

    RedPacketInfoModel redPacketInfoModel;

    @Override
    public void parseInfo(String content) throws JSONException {
        redPacketInfoModel = App.getGson().fromJson(content, RedPacketInfoModel.class);
    }

    public List<RedPacketInfoModel.RedpackListBean> getRedpackList() {
        if (redPacketInfoModel == null) {
            return Collections.emptyList();
        } else {

            List<RedPacketInfoModel.RedpackListBean> redpackListBeans = redPacketInfoModel.getRedpack_list();
            for (int i = 0; i < redpackListBeans.size(); i++) {
                if (redpackListBeans.get(i).getDay() <= redPacketInfoModel.getContinuity()) {
                    redpackListBeans.get(i).setHasSignature(true);
                } else {
                    redpackListBeans.get(i).setHasSignature(false);
                }
            }

            return redpackListBeans;
        }
    }

    public List<RedPacketInfoModel.PrizeInfoBean> getPrizeList() {
        if (redPacketInfoModel == null) {
            return Collections.emptyList();
        } else {
            return redPacketInfoModel.getPrize_info();
        }
    }

    public RedPacketInfoModel getRedPacketInfoModel() {
        return redPacketInfoModel;
    }
}
